package day04;

import java.util.Enumeration;
import java.util.Scanner;

//猜数字小游戏
public class Guessing {
    public static void main(String[] args) {
        /*
        int num =(int)(Math.random()*1000+1);
        Scanner scanner = new Scanner(System.in);
        int guess;//作用域
        do{
            System.out.println("猜吧");
            guess =scanner.nextInt();
            if(guess > num){
                System.out.println("猜大了");
            }else if(guess < num){
                System.out.println("猜小了");
            }else {
                System.out.println("对了");//也可以放在最后
            }
        }while (guess != num);

         */




        /*
        Math.random()-----------0.0到0.9999999999999...
        *1000-------------------0.0到999.99999999999...
        +1----------------------1.0带1000.9999999999...
        (int)-------------------1到1000
         */

        /*
        Scanner scanner = new Scanner(System.in);
        int guess = (int)(Math.random()*1000+1);
        System.out.println(guess);
        int num = scanner.nextInt();
        while (num != guess) {
            if(num < guess){
                System.out.println("猜小了!继续猜吧:");
            }else {
                System.out.println("猜大了!继续猜吧:");
            }
            num = scanner.nextInt();
        }
        System.out.println("猜对了");

         */
        }
    }

